// 导入axios
import axios from 'axios';
import Vue from 'vue';
import {
	Toast
} from 'vant';
Vue.use(Toast);
var toast = null;
var request = axios.create({
	baseURL: "/",
	timeout: 50000,
})

request.interceptors.request.use(function(config) {
	config.headers.Authorization = 'Bearer ' + localStorage.getItem("token");
	if(config.loading){
		toast = Toast.loading({
			message: '加载中...',
			forbidClick: true,
		});
	}
	return config;
})

request.interceptors.response.use(
	function(res) {
		toast ? toast.clear() : "";
		return res;
	},
	function(err) {
		toast ? toast.clear() : "";
		return err;
	}
)



// 导出
export default request;
